#!/bin/sh
# Download music from libreboot's free music repository

[ ${#} -ne 1 ] && printf 'USAGE:\tlbmdl <destination>.\n' 1>&2 && exit 1

readonly remote=rsync://rsync.libreboot.org/music

printf '%s currently contains %sG of data.\n\n' \
	"${remote}" \
	"$(rsync -r "${remote}" \
		| awk '{ gsub(/,/,"",$2); s += $2 } END \
			{ print (s / 1073741824) }' \
	)"

# Mirror changes from remote repository to local destination folder
#	- Newer files won't be updated
#	- Files will never be deleted
rsync -r -u -l -H -m -I -h -P --exclude=index.php \
	"${remote}" \
	"${1}"

printf 'See %s for tips on how to transcode multiple FLAC files.\n' \
	'https://wiki.archlinux.org/index.php/Convert_Flac_to_Mp3'
